//==================================================================
/// CppKazRace.h
///
/// Created by Davide Pasca - 2009/10/5
/// See the file "license.txt" that comes with this project for
/// copyright info. 
//==================================================================

#ifndef CPPKAZRACE_H
#define CPPKAZRACE_H

#include "printout.h"
#include "horizont.h"
#include "transformer.h"
#include "font.h"
#include "road.h"
#include "sprite.h"
#include "PlayerCar.h"

//==================================================================
//==================================================================
class CppKazRace
{
	adel<printout>		mpoPO;
	adel<horizon>		mpoHor;
	adel<transformer>	mpoXFormer;
	adel<Font>			mpoFont;
	adel<road>			mpoRoad;

	adel<sprite>		mpoMyCarSptr;
	adel<sprite>		mpoF500;
	adel<sprite>		mpoMoo;
	adel<sprite>		mpoSmokeSprt;

	adel<sprite>		mpoRQueen1;
	adel<sprite>		mpoRQueen2;
	adel<sprite>		mpoRQueen3;
	adel<sprite>		mpoRQueen4;

	adel<sprite>		mpoStartFrame;

	adel<particler>		mpoSmokeLPart;
	adel<particler>		mpoSmokeRPart;

	adel<graphics>		mpoOffGfx;
	bool				mOffGfxIsBGR;

	VecOwn<sprite*>		mpoSprites;

	float				mScreenD;

	bool				mLeftIsDown;
	bool				mRightIsDown;
	bool				mUpIsDown;
	bool				mDownIsDown;

	VecOwn<vehicle*>	mpoVehicles;

	DVec<long>			_laptimes;
	int					_n_laps;

	Dimension			mCurWinSize;

	PlayerCar			mPlayerCar;

public:
	CppKazRace();

	~CppKazRace()
	{
	}

	//==================================================================
	void anim_cars();

	//==================================================================
	void animate();

	//==================================================================
	void lap_add_new();

	//==================================================================
	void lap_draw( graphics &g );

	//==================================================================
	void mypaint();

	//==================================================================
	void load_cars();

	//==================================================================
	void reset_pos();

	//==================================================================
	void load_road();
	//==================================================================
	void load_stage();

	//==================================================================
	void init();

	//==================================================================
	static bool EvenCB_s( void *pUserData, HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam )
	{
		return ((CppKazRace *)pUserData)->EvenCB( hWnd, message, wParam, lParam );
	}

private:
	bool EvenCB( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam );

	void onPaint( HWND hWnd );
	Dimension getDispSize() const	{ return mCurWinSize; }

	void onResize( U32 w, U32 h );
};

#endif
